﻿using System.Data;
using ET;
namespace DA
{
    public class Customer_DAL
    {
        private clsConnect cls = new clsConnect();

        #region Getdata
        public DataTable BindGirdtb_Customer(string keywords)
        {
            return cls.Search("sp_tb_Customer_Search", "@KeyWords", keywords);
        }
        public DataTable GetCustomerDetail(int id)
        {
            return cls.GetData_ID_Int("sp_tb_Customer_Search_Edit", "@Customer_ID", id);
        }
        #endregion

        #region Insert
        public bool Inserttb_Customer(Customer_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Customer_Alias", data.Customer_Alias);
            cls.AddParameter("@Customer_Type_ID", data.Customer_Type_ID);
            cls.AddParameter("@Customer_Shortcut", data.Customer_Shortcut);
            cls.AddParameter("@Customer_Name", data.Customer_Name);
            cls.AddParameter("@Customer_Name_EN", data.Customer_Name_EN);
            cls.AddParameter("@Customer_Name_Exchange", data.Customer_Name_Exchange);
            cls.AddParameter("@Enterprise_ID", data.Enterprise_ID);
            cls.AddParameter("@Customer_Debt_Limit", data.Customer_Debt_Limit);
            cls.AddParameter("@Customer_Address", data.Customer_Address);
            cls.AddParameter("@Customer_Payment_Deadline", data.Customer_Payment_Deadline);
            cls.AddParameter("@District_ID", data.District_ID);
            cls.AddParameter("@Customer_Establish", data.Customer_Establish);
            cls.AddParameter("@Customer_Phone1", data.Customer_Phone1);
            cls.AddParameter("@Customer_Phone2", data.Customer_Phone2);
            cls.AddParameter("@Customer_Fax", data.Customer_Fax);
            cls.AddParameter("@Customer_Website", data.Customer_Website);
            cls.AddParameter("@Sector_ID", data.Sector_ID);
            cls.AddParameter("@Customer_Account_Number", data.Customer_Account_Number);
            cls.AddParameter("@Customer_Contact", data.Customer_Contact);
            cls.AddParameter("@Bank_ID", data.Bank_ID);
            cls.AddParameter("@Customer_Contract_FullName", data.Customer_Contract_FullName);
            cls.AddParameter("@Customer_Contract_Address", data.Customer_Contract_Address);
            cls.AddParameter("@Customer_Contract_District", data.Customer_Contract_District);
            cls.AddParameter("@Customer_Contract_Tax_Code", data.Customer_Contract_Tax_Code);
            cls.AddParameter("@Customer_Contract_Contact", data.Customer_Contract_Contact);
            cls.AddParameter("@Customer_Delivery_Address", data.Customer_Delivery_Address);
            cls.AddParameter("@Customer_Delivery_Contact", data.Customer_Delivery_Contact);
            cls.AddParameter("@Customer_Payment_Address", data.Customer_Payment_Address);
            cls.AddParameter("@Customer_Payment_Contact", data.Customer_Payment_Contact);
            cls.AddParameter("@Customer_Note", data.Customer_Note);
            cls.AddParameter("@Customer_User_Add", data.Customer_User_Add);
            cls.AddParameter("@Customer_Date_Add", data.Customer_Date_Add);
            cls.AddParameter("@Customer_Computer_Add", data.Customer_Computer_Add);
            cls.AddParameter("@Customer_User_Modify", data.Customer_User_Modify);
            cls.AddParameter("@Customer_Date_Modify", data.Customer_Date_Modify);
            cls.AddParameter("@Customer_Computer_Modify", data.Customer_Computer_Modify);
            cls.ExecuteNonQuery("sp_tb_Customer_Insert");
            return true;
        }
        #endregion

        #region Update
        public bool Updatetb_Customer(Customer_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Customer_ID", data.Customer_ID);
            cls.AddParameter("@Customer_Alias", data.Customer_Alias);
            cls.AddParameter("@Customer_Type_ID", data.Customer_Type_ID);
            cls.AddParameter("@Customer_Shortcut", data.Customer_Shortcut);
            cls.AddParameter("@Customer_Name", data.Customer_Name);
            cls.AddParameter("@Customer_Name_EN", data.Customer_Name_EN);
            cls.AddParameter("@Customer_Name_Exchange", data.Customer_Name_Exchange);
            cls.AddParameter("@Enterprise_ID", data.Enterprise_ID);
            cls.AddParameter("@Customer_Debt_Limit", data.Customer_Debt_Limit);
            cls.AddParameter("@Customer_Address", data.Customer_Address);
            cls.AddParameter("@Customer_Payment_Deadline", data.Customer_Payment_Deadline);
            cls.AddParameter("@District_ID", data.District_ID);
            cls.AddParameter("@Customer_Establish", data.Customer_Establish);
            cls.AddParameter("@Customer_Phone1", data.Customer_Phone1);
            cls.AddParameter("@Customer_Phone2", data.Customer_Phone2);
            cls.AddParameter("@Customer_Fax", data.Customer_Fax);
            cls.AddParameter("@Customer_Website", data.Customer_Website);
            cls.AddParameter("@Sector_ID", data.Sector_ID);
            cls.AddParameter("@Customer_Account_Number", data.Customer_Account_Number);
            cls.AddParameter("@Customer_Contact", data.Customer_Contact);
            cls.AddParameter("@Bank_ID", data.Bank_ID);
            cls.AddParameter("@Customer_Contract_FullName", data.Customer_Contract_FullName);
            cls.AddParameter("@Customer_Contract_Address", data.Customer_Contract_Address);
            cls.AddParameter("@Customer_Contract_District", data.Customer_Contract_District);
            cls.AddParameter("@Customer_Contract_Tax_Code", data.Customer_Contract_Tax_Code);
            cls.AddParameter("@Customer_Contract_Contact", data.Customer_Contract_Contact);
            cls.AddParameter("@Customer_Delivery_Address", data.Customer_Delivery_Address);
            cls.AddParameter("@Customer_Delivery_Contact", data.Customer_Delivery_Contact);
            cls.AddParameter("@Customer_Payment_Address", data.Customer_Payment_Address);
            cls.AddParameter("@Customer_Payment_Contact", data.Customer_Payment_Contact);
            cls.AddParameter("@Customer_Note", data.Customer_Note);
            cls.AddParameter("@Customer_User_Add", data.Customer_User_Add);
            cls.AddParameter("@Customer_Date_Add", data.Customer_Date_Add);
            cls.AddParameter("@Customer_Computer_Add", data.Customer_Computer_Add);
            cls.AddParameter("@Customer_User_Modify", data.Customer_User_Modify);
            cls.AddParameter("@Customer_Date_Modify", data.Customer_Date_Modify);
            cls.AddParameter("@Customer_Computer_Modify", data.Customer_Computer_Modify);
            cls.ExecuteNonQuery("sp_tb_Customer_Update");
            return true;
        }
        #endregion

        #region Delete
        public bool Deletetb_Customer(int id)
        {
            cls.Delete("sp_tb_Customer_Delete", "@Customer_ID",id);
            return true;
        }
        #endregion
    }
}